aboutsummaryrefslogtreecommitdiff
path: root/src/app/anime/[id]/page.jsx
blob: 751acef4f3a957e69e7cd206006c100bd9550b07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import "./info.css";
import Image from "next/image";
import Link from "next/link";

export default async function AnimeInfo({ params }) {
	let animeID = params.id;

	const info = await getAnimeInfo(animeID);

	return (
		<div className="dramaInfoContainer">
			<div className="dramaInfo">
				{info && (
					<div>
						<div className="titleContainer">
							<p>{info.title}</p>
							<Image
								src={info.image}
								width={150}
								height={200}
								alt="Drama"
							/>
						</div>
						<p className="animeDescription">{info.description}</p>
					</div>
				)}

				<div className="animeDetails">
					<span>Genres: </span>
					{info.genres &&
						info.genres.map((item, index) => (
							<span className="genreEntries" key={index}>
								{item}
							</span>
						))}
					<p className="animeType">
						Type: <span>{info.type}</span>
					</p>
					<p className="animeRelease">
						Release year:{" "}
						<span>
							{info.releaseDate}, {info.status}
						</span>
					</p>
				</div>

				<div className="buttonContainer">
					{info &&
						info.episodes.map((item, index) => (
							<Link href={`/anime/watch/${item.id}`} key={index}>
								<button className="dramaButton">
									<span>Episode </span>
									{item.number}
								</button>
							</Link>
						))}
				</div>
			</div>
		</div>
	);
}

async function getAnimeInfo(anime_id) {
	const res = await fetch(
		"https://anime-sensei-api.vercel.app/anime/gogoanime/info/" + anime_id,
		{ next: { revalidate: 1800 } }
	);
	const data = res.json();
	return data;
}